package com.wwlwxg.spring_security.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;

@Slf4j
@RestController
public class DbController {

  @Autowired
  private JdbcTemplate jdbcTemplate;

  @Autowired
  private DataSource dataSource;

  @GetMapping("/get")
  public void contextLoads() {
    Long id = jdbcTemplate.queryForObject("select id from t_users where id = 1", Long.class);
    log.info("记录总数： {} ", id);
    log.info("数据源类型： {}", dataSource.getClass());
  }
}
